package pumpeddevs.game.framework;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;

public abstract class PDSprite {
	protected int _x;
	protected int _y;
	protected int _velocityX;
	protected int _velocityY;
	protected Bitmap _bitmap;
	protected Context _context;
	protected ArrayList<Bitmap> _images;
	protected int _screenWidth;
	protected int _screenHeight;
	protected int _height;
	protected int _width;
	
	public void setScreenDimension(int screenWidth, int screenHeight) {
		this._screenWidth = screenWidth;
		this._screenHeight = screenHeight;
	}
	
	public PDSprite(Context context, int[] resourceDrawables) {
		this._context = context;
		this._images = new ArrayList<Bitmap>();
		for(int i = 0 ; i < resourceDrawables.length; i++) {
			BitmapDrawable bitmapDrawable = (BitmapDrawable) this._context.getResources().getDrawable(resourceDrawables[i]);
			this._images.add(bitmapDrawable.getBitmap());
		}
	}
	
	public PDSprite(Context context, String[] resourceDrawables) {
		this._context = context;
		this._images = new ArrayList<Bitmap>();
		for(int i = 0 ; i < resourceDrawables.length; i++) {
			int res = this._context.getResources().getIdentifier(resourceDrawables[i], "string", this._context.getPackageName());
			BitmapDrawable bitmapDrawable = (BitmapDrawable) this._context.getResources().getDrawable(res);
			this._images.add(bitmapDrawable.getBitmap());
		}
	}
	
	public PDSprite(Context context) {
		this._context = context;
	}
	
	public PDSprite(Context context, int resourceDrawable) {
		this._context = context;
		BitmapDrawable bitmapDrawable = (BitmapDrawable) this._context.getResources().getDrawable(resourceDrawable);
		this._bitmap = bitmapDrawable.getBitmap();
	}
	
	public void render(Canvas canvas) {
		canvas.drawBitmap(this._bitmap, this._x, this._y, null);
	}
	
	public void setX(int x) {
		this._x = x;
	}
	
	public void setY(int y) {
		this._y = y;
	}
	
	public void setCoordinate(int x, int y) {
		this._x = x;
		this._y = y;
	}
	
	public Bitmap getBitmap() {
		return this._bitmap;
	}
	
	public void setBitmap(Bitmap bitmap) {
		this._bitmap = bitmap;
	}
	
	public Bitmap getBitmap(int resourceDrawable) {
		BitmapDrawable bitmapDrawable = (BitmapDrawable) this._context.getResources().getDrawable(resourceDrawable);
		return bitmapDrawable.getBitmap();
	}
}
